package com.lwq.model;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.lwq.util.DateUtil;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * Description:
 * Author: LiuWenQing
 * Datetime: 2021/6/10
 */
@Data
public class BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableField(fill = FieldFill.INSERT )
    @DateTimeFormat(pattern = DateUtil.YYYY_MM_DD_HH_MM_SS)
    @JsonFormat(pattern = DateUtil.YYYY_MM_DD_HH_MM_SS)
    private Date createDate;

    @TableField(fill = FieldFill.INSERT )
    @JsonSerialize(using = ToStringSerializer.class)
    private Long createId;

    @TableField(fill = FieldFill.INSERT_UPDATE,update = "now()")
    @DateTimeFormat(pattern = DateUtil.YYYY_MM_DD_HH_MM_SS)
    @JsonFormat(pattern = DateUtil.YYYY_MM_DD_HH_MM_SS)
    private Date updateDate;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long updateId;
}
